package reflect.demo;

public class Test6 {
    public static void main(String[] args) {
        Class clz= null;  //加载Person类
        try {
            clz = Class.forName("reflect.entity.Person");
            Object obj= null;   //调用Person类的无参构造创建Person类的实例
            try {
                obj = clz.newInstance();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
            System.out.println(obj);    //调用Person实例的toString()方法，属性均为默认值
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
